#include<iostream>
#include<vector>
using namespace std;


vector<int> twoSum(vector<int>& price, int target) {
    int n = price.size();
    vector<int> res;
    int left = 0, right = n - 1;
    while (left < right)
    {
        if (price[left] + price[right] > target) right--;
        else if (price[left] + price[right] < target) left++;
        else
        {
            res.push_back(price[left]);
            res.push_back(price[right]);
            break;
        }
    }
    return res;
}

int main()
{
    vector<int>price = { 3, 9, 12, 15 };
    twoSum(price,18);
    return 0;
}